class Rapid < Download
require 'uri'
require 'net/http'
	def start
		url=URI.parse(@link)
		req = Net::HTTP::Get.new(url.path)
		res = Net::HTTP.start(url.host, url.port) {|http|
			http.request(req)
		}
		res = Net::HTTP.post_form(URI.parse(res.body.scan(/(http\:\/\/[a-z0-9]+\.rapidshare\.com\/files\/.+)\"\s/).to_s),{'dl.start'=>'Free'})
		espera = res.body.scan(/var c=(\d+)/)[0][0]
		size = res.body.scan(/\| (\d+) KB/)[0][0]
		puts "esperando "+espera
		sleep espera.to_i
		descurl = res.body.scan(/(http\:\/\/[a-zA-Z0-9]+\.rapidshare\.com\/files\/\d+\/\d+\/.+)\"\smethod/).to_s
		@name = res.body.scan(/(http\:\/\/[a-zA-Z0-9]+\.rapidshare\.com\/files\/\d+\/\d+\/.+)\"\smethod/).to_s.split("/")[-1]
		link = URI.parse(URI.escape(descurl))
		http2 = Net::HTTP.new(link.host, link.port)
		File.open(File.join(@tempdir,@name),"wb"){ |file|
 			http2.get(link.request_uri) do |str|
				file.write str
        		end
		}
	end
end
